import React, {memo, useCallback, useEffect} from 'react';
import {Button, Result} from "antd";

export default memo(function AdminError(props) {
  const {history} = props;
  const {userId} = props.route;

  useEffect(() => {
    userId ? history.push(`/admin/home/u/${userId}`) : history.push("/")
  }, [userId, history])

  const handleClick = useCallback(() => {
    userId ? history.push(`/admin/home/u/${userId}`) : history.push("/")
  }, [history, userId])

  return (
    <div>
      <Result
        status="404"
        title="404"
        subTitle="资源不存在.."
        extra={<Button type="primary" onClick={handleClick}>回到工作台</Button>}
      />
    </div>
  )
})